package com.store.app.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.store.app.BaseActivity;
import com.store.app.R;
import com.store.app.adapter.AutoDeviceListAdapter;
import com.store.app.bean.SpecialsellDeviceBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/5/31.
 */

public class AutomaticSellListActivity extends BaseActivity  {
    private ImageView public_ll_return;
    private TextView tvTitle;
    private TextView public_tv_right;
    private ListView lv;
    private ImageView iv_add;
    private List<SpecialsellDeviceBean> specialsellDeviceBeanList;
    private AutoDeviceListAdapter autoDeviceListAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_automatic_sell);
        initView();
        initData();

    }
    private void initData(){
        specialsellDeviceBeanList = new ArrayList<>();
        List<SpecialsellDeviceBean> temList = getIntent().getParcelableArrayListExtra("data");
        Log.v("zyl","temList:"+temList.size());
        if(temList!=null&&temList.size()!=0){
            specialsellDeviceBeanList.clear();
            specialsellDeviceBeanList.addAll(temList);
        }
        autoDeviceListAdapter = new AutoDeviceListAdapter(this, specialsellDeviceBeanList, new AutoDeviceListAdapter.onClickButton() {
            @Override
            public void detailsClick(SpecialsellDeviceBean bean) {

            }
        });
        lv.setAdapter(autoDeviceListAdapter);
    }

    private void initView() {
        public_ll_return = (ImageView) findViewById(R.id.public_ll_return);
        tvTitle = (TextView) findViewById(R.id.tvTitle);
        tvTitle.setText("自动售货机");
        public_tv_right = (TextView) findViewById(R.id.public_tv_right);
        lv = (ListView) findViewById(R.id.listview);
        iv_add = (ImageView) findViewById(R.id.iv_add);
        iv_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(AutomaticSellListActivity.this,AddDeviceActivity.class));
            }
        });
        public_ll_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
}
